package com.vhly.ddxdecompiler.dexreader.file.mixeditem;

import com.vhly.ddxdecompiler.dexreader.file.DexFile;
import com.vhly.ddxdecompiler.dexreader.io.DexInputStream;

import java.io.DataOutputStream;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: vhly
 * Date: 2009-10-15
 * Time: 12:47:30
 *
 * @author vhly[FR]
 */
public final class StringIdItem extends IndexedItem {
    public int dataOffset;
    private StringDataItem data;
    private String value;
    private DexFile dexFile;

    public StringIdItem(DexFile dex) {
        dexFile = dex;
    }

    public void read(DexInputStream din) throws IOException {
        dataOffset = din.readInt();
    }

    public void write(DataOutputStream dout) throws IOException {
        dout.writeInt(dataOffset);
    }

    public void setDataItem(StringDataItem dataItem) {
        data = dataItem;
        if (dataItem.value != null) {
            this.value = dataItem.value;
        }
    }

    public StringDataItem getDataItem() {
        return data;
    }

    @Override
    public String toString() {
        return value;
    }
}
